package com.linkage.educloud.ah.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.linkage.educloud.ah.data.CursorHelper;
import com.linkage.educloud.ah.data.Ws;


public class ClazzContact implements Parcelable {
	/**
	 * 
	 */
	private static final long serialVersionUID = -5139694244929280830L;
	public long id;
	public String remoteId;
	public long newclassid;

	public String name;
	public int type;
	public int role;
	public String dn;// "手机号码"
	public String short_dn;// 短号
	public long classid;
	public String className;
	public String schoolName;
	private boolean isSelected;
	public String avatar_url;
	public int invite;
	public int studentid;
	public String studentname;
	public String student_relation;
	public int isopen_phone;
	public int login_type;
	public String firstName;//名字首字母

	public ClazzContact() {
	}

	public int getStudentid() {
		return studentid;
	}

	public void setStudentid(int studentid) {
		this.studentid = studentid;
	}

	public String getStudentname() {
		return studentname;
	}

	public void setStudentname(String studentname) {
		this.studentname = studentname;
	}

	public String getStudent_relation() {
		return student_relation;
	}

	public void setStudent_relation(String student_relation) {
		this.student_relation = student_relation;
	}

	public int getIsopen_phone() {
		return isopen_phone;
	}

	public void setIsopen_phone(int isopen_phone) {
		this.isopen_phone = isopen_phone;
	}

	public boolean isSelected() {
		return isSelected;
	}

	public void setSelected(boolean isSelected) {
		this.isSelected = isSelected;
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getRemoteId() {
		return remoteId;
	}

	public void setRemoteId(String remoteId) {
		this.remoteId = remoteId;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public int getRole() {
		return role;
	}

	public void setRole(int role) {
		this.role = role;
	}

	public String getDn() {
		return dn;
	}

	public void setDn(String dn) {
		this.dn = dn;
	}

	public String getShort_dn() {
		return short_dn;
	}

	public void setShort_dn(String short_dn) {
		this.short_dn = short_dn;
	}

	public long getClassid() {
		return classid;
	}

	public void setClassid(long classid) {
		this.classid = classid;
	}

	public String getClassName() {
		return className;
	}

	public void setClassName(String className) {
		this.className = className;
	}

	public String getSchoolName() {
		return schoolName;
	}

	public void setSchoolName(String schoolName) {
		this.schoolName = schoolName;
	}

	public String getAvatar_url() {
		return avatar_url;
	}

	public void setAvatar_url(String avatar_url) {
		this.avatar_url = avatar_url;
	}

	public long getNewclassid() {
		return newclassid;
	}

	public void setNewclassid(long newclassid) {
		this.newclassid = newclassid;
	}

	public int getInvite() {
		return invite;
	}

	public void setInvite(int invite) {
		this.invite = invite;
	}

	public int getLogin_type() {
		return login_type;
	}

	public void setLogin_type(int login_type) {
		this.login_type = login_type;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public static ClazzContact fromCursor (CursorHelper helper){

		ClazzContact contact = new ClazzContact();
		contact.setId(helper.getLong(Ws.ContactTable.ID));
		contact.setRemoteId(helper.getString(Ws.ContactTable.REMOTEID));
		contact.setClassid(helper.getLong(Ws.ContactTable.GROUP_ID));
		contact.setName(helper.getString(Ws.ContactTable.NAME));
		contact.setFirstName(helper.getString(Ws.ContactTable.FIRSTNAME));
		contact.setType(helper.getInt(Ws.ContactTable.TYPE));
		contact.setDn(helper.getString(Ws.ContactTable.PHONE));
		contact.setShort_dn(helper.getString(Ws.ContactTable.SHORT_DN));
		contact.setClassName(helper.getString(Ws.ContactTable.CLASS_NAME));
		contact.setSchoolName(helper.getString(Ws.ContactTable.SCHOOL_NAME));
		contact.setIsopen_phone(helper.getInt(Ws.ContactTable.ISOPENPHONE));
		contact.setAvatar_url(helper.getString(Ws.ContactTable.AVATAR_URL));
		contact.setInvite(helper.getInt(Ws.ContactTable.INVITE));
		contact.setLogin_type(helper.getInt(Ws.ContactTable.STATUS));
		contact.setStudentid(helper.getInt(Ws.ContactTable.STUDENT_ID));
		contact.setStudentname(helper.getString(Ws.ContactTable.STUDENT_NAME));
		contact.setStudent_relation(helper.getString(Ws.ContactTable.STUDENT_RELATIVE));
		return contact;
	}

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeLong(this.id);
		dest.writeString(this.remoteId);
		dest.writeLong(this.newclassid);
		dest.writeString(this.name);
		dest.writeInt(this.type);
		dest.writeInt(this.role);
		dest.writeString(this.dn);
		dest.writeString(this.short_dn);
		dest.writeLong(this.classid);
		dest.writeString(this.className);
		dest.writeString(this.schoolName);
		dest.writeByte(this.isSelected ? (byte) 1 : (byte) 0);
		dest.writeString(this.avatar_url);
		dest.writeInt(this.invite);
		dest.writeInt(this.studentid);
		dest.writeString(this.studentname);
		dest.writeString(this.student_relation);
		dest.writeInt(this.isopen_phone);
		dest.writeInt(this.login_type);
		dest.writeString(this.firstName);
	}

	protected ClazzContact(Parcel in) {
		this.id = in.readLong();
		this.remoteId = in.readString();
		this.newclassid = in.readLong();
		this.name = in.readString();
		this.type = in.readInt();
		this.role = in.readInt();
		this.dn = in.readString();
		this.short_dn = in.readString();
		this.classid = in.readLong();
		this.className = in.readString();
		this.schoolName = in.readString();
		this.isSelected = in.readByte() != 0;
		this.avatar_url = in.readString();
		this.invite = in.readInt();
		this.studentid = in.readInt();
		this.studentname = in.readString();
		this.student_relation = in.readString();
		this.isopen_phone = in.readInt();
		this.login_type = in.readInt();
		this.firstName = in.readString();
	}

	public static final Parcelable.Creator<ClazzContact> CREATOR = new Parcelable.Creator<ClazzContact>() {
		@Override
		public ClazzContact createFromParcel(Parcel source) {
			return new ClazzContact(source);
		}

		@Override
		public ClazzContact[] newArray(int size) {
			return new ClazzContact[size];
		}
	};

	public interface ContactType{
		int PARENT = 1;
		int TEACHER = 2;
	}
}
